/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.util.Objects;

/**
 *
 * @author 乐山
 */
public class Person {

    /**
     * 学号
     */
    private String id;
    private String name;
    /**
     * 班级
     */
    private String clazz;
    private Grades grades = new Grades();

    public Person() {
    }

    public Person(String id, String name, String clazz) {
        this.id = id;
        this.name = name;
        this.clazz = clazz;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getClazz() {
        return clazz;
    }

    public void setClazz(String clazz) {
        this.clazz = clazz;
    }

    public Grades getGrade() {
        return grades;
    }

    public void setGrade(Grades grade) {
        this.grades = grade;
    }

    @Override
    public String toString() {
        return "Person{" + "id=" + id + ", name=" + name + ", clazz=" + clazz + ", grades=" + grades + '}';
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 97 * hash + Objects.hashCode(this.id);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Person other = (Person) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        return true;
    }

    /**
     * 根据grade.type(修习类别)的取值将成绩放到哪个类型的成绩列表
     *
     * @param grade
     */
    public void putGrade(CourseGrade grade) {
        String type = grade.getType();
        switch (type) {
            case "基础选修":
                grades.getBasicEC().add(grade);
                break;
            case "专业必修":
                grades.getSpecialRC().add(grade);
                break;
            case "专业选修":
                grades.getSpecialEC().add(grade);
                break;
            default:
        }
    }

}
